package com.rcmd.agent;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
	private int port ;
	private ServerSocket ss ;
	public Server( int port){
		this.port = port ;
	}
	public void startServer() throws IOException{
		ss = new ServerSocket(port) ;
		System.out.println("open port at: " + port) ;
		while(true){
			
			Socket client = ss.accept();
			Proc p = new Proc(client) ;
			p.start() ;
		}
		
		
	}
	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		int port =1212 ;
		if( args.length > 0) 
			port=Integer.parseInt(args[0]) ;
		Server s = new Server(port) ;
		s.startServer();
	}

}
